From: Keir Fraser Date: Fri, 16 Oct 2009 07:25:17 +0000 (+0100) Subject: x86: Fix ept and vt-d co-existence issue. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~13219 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=c5ff46d8d46a97bf0d491d226f5092f698ffff96;p=xen.git x86: Fix ept and vt-d co-existence issue. For vt-d's mmio address ranges, once ept enables, they should be added to ept page tables with p2m lock held, and then guest can access these ranges like conventional ram, but to change the ept entries, it should take the p2m lock first. Signed-off-by: Xiantao Zhang --- diff --git a/xen/arch/x86/mm/hap/p2m-ept.c b/xen/arch/x86/mm/hap/p2m-ept.c index 47c7be8a57..35c81c6b5b 100644 --- a/xen/arch/x86/mm/hap/p2m-ept.c +++ b/xen/arch/x86/mm/hap/p2m-ept.c @@ -524,6 +524,7 @@ void ept_change_entry_emt_with_range(struct domain *d, unsigned long start_gfn, mfn_t mfn; int order = 0; + p2m_lock(d->arch.p2m); for ( gfn = start_gfn; gfn <= end_gfn; gfn++ ) { e = ept_get_entry_content(d, gfn); @@ -561,6 +562,7 @@ void ept_change_entry_emt_with_range(struct domain *d, unsigned long start_gfn, ept_set_entry(d, gfn, mfn, order, e.avail1); } } + p2m_unlock(d->arch.p2m); } /* diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 77ed7f2ca5..66069ce442 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -2237,7 +2237,9 @@ set_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn) } P2M_DEBUG("set mmio %lx %lx\n", gfn, mfn_x(mfn)); + p2m_lock(d->arch.p2m); rc = set_p2m_entry(d, gfn, mfn, 0, p2m_mmio_direct); + p2m_unlock(d->arch.p2m); if ( 0 == rc ) gdprintk(XENLOG_ERR, "set_mmio_p2m_entry: set_p2m_entry failed! mfn=%08lx\n", @@ -2261,7 +2263,9 @@ clear_mmio_p2m_entry(struct domain *d, unsigned long gfn) "clear_mmio_p2m_entry: gfn_to_mfn failed! gfn=%08lx\n", gfn); return 0; } + p2m_lock(d->arch.p2m); rc = set_p2m_entry(d, gfn, _mfn(INVALID_MFN), 0, 0); + p2m_unlock(d->arch.p2m); return rc; }